using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Sedna.Core.Controller;
using Sedna.Core.Controller.Common;
using Sedna.Core.Controls.Support;
using Iesi.Collections;
using Spring.Util;

namespace Sedna.Core.Controls.Actions
{
    public class MarkedDataToIdArray: AbstractAction
    {
        #region Fields
        
        private IDataGridController controller;
        private String idName;
        
        #endregion

        #region Properties

        public string IdName
        {
            set { idName = value; }
        }

        #endregion

        public override IActionResult Execute(IExecutionContext executionContext)
        {
            ArrayList result = new ArrayList();
            foreach (Object o in controller.MarkedData)
            {
                result.Add(o.GetType().GetProperty(idName).GetValue(o, null));
            }
            executionContext.CallContext.Result = result;
            return CreateResult();
        }
    }
}
